$(function () {


    $("#switch_button").switchbutton({
        onChange: function (checked) {
            if (checked) {
                var mixNumber = $("#mixNumber").val();
                $.post("/comallocation/save", {mixNumber: mixNumber}, function (data) {
                    if (data.success) {
                        $.messager.alert("温馨提醒", "保存成功", "info");
                    } else {
                        $.messager.alert("温馨提醒", "保存失败", "error");
                    }
                })
            }
        }
    });
    var box = $("#test input:checkbox");
    box.click(function () {
        if (this.checked) {
            box.removeAttr("checked");
            $(this).prop("checked", true)
        }
    })
    $("#btn").linkbutton({
        onClick: function () {
            var test = $("#test").val();
            $.post("/comallocation/save", {test: test}, function (data) {
                if (data.success) {
                    $.messager.alert("温馨提醒", "保存成功", "info");
                } else {
                    $.messager.alert("温馨提醒", "保存失败", "error");
                }
            })
        }
    });

    //----------------------------------------

    var methodObj = {
        add: function () {
            $("#Adding_unit").dialog({
                width: 260,
                height: 150

            });
        },
        add1: function () {
            $("#Add_class").dialog({
                width: 260,
                height: 150
            });
        }
    }
    $("a[data-cmd]").click(function () {
        var methodName = $(this).data("cmd");
        methodObj[methodName]();
    })


});